/**
 * Created by OneDream on 2016/1/4.
 */
$(document).ready(function(){
    var img=$("#foot img");
    var height=$(window).height();
    var width=$(window).width();
    $("#container").css("height",height);
    $("#head").css("height","5%");
    $("#content").css("height","82%");
    $("#foot").css("height","10%");
    $("#head img").click(function(){
        window.location.href="addFriend.html"
    });
        if(localStorage.getItem("iframesrc")=="message_recorded"){
            tab_normal();
            $("iframe").attr("src","message_recorded.html");
            $(img[0]).attr("src","image/message_pressed.png");
            $("#title_text").html("微信");
            $("#title_img").css("display","block");
            $("#title_img").attr("src","image/messageadd.png")
        }
        if(localStorage.getItem("iframesrc")=="contact"){
           // alert("tab2");
            tab_normal();
            $("iframe").attr("src","contact.html");
            $(img[1]).attr("src","image/contact_pressed.png");
            //$("#search_i").css("display","block");
            $("#title_img").css("display","block");
            $("#title_img").attr("src","image/contactadd.png");
            $("#title_text").html("通讯录");
        }
        if(localStorage.getItem("iframesrc")=="find"){
        // alert("tab2");
            tab_normal();
            $("iframe").attr("src","friendgroup.html");
            $(img[2]).attr("src","image/find_pressed.png");
            //$("#search_i").css("display","block");
            $("#title_img").css("display","none");
            $("#title_text").html("发现");
         }
        if(localStorage.getItem("iframesrc")=="me"){
        // alert("tab2");
            tab_normal();
            $("iframe").attr("src","me.html");
            $(img[3]).attr("src","image/me_pressed.png");
            //$("#search_i").css("display","block");
            $("#title_img").css("display","none");
            $("#title_text").html("发现");
         }

var img=$("#foot img");
    //alert(img.length);
    $.each(img,function(i,item){
        $(item).click(function(){
            //alert(img.length);
            tab_normal();
            switch (i){
                case 0:
                    localStorage.setItem("iframesrc","message_recorded");
                    //$("iframe").attr("src","none");
                    $("iframe").attr("src","message_recorded.html");
                    $(img[0]).attr("src","image/message_pressed.png");
                    $("#title_text").html("微信");
                    //$("#search_i").css("display","none");
                    $("#title_img").css("display","block");
                    $("#title_img").attr("src","image/messageadd.png");
                   // $("#content").html("TAB01");
                    break;
                case 1:
                    localStorage.setItem("iframesrc","contact");
                    $("iframe").attr("src","contact.html");
                    $(img[1]).attr("src","image/contact_pressed.png");
                    //$("#search_i").css("display","block");
                    $("#title_img").css("display","block");
                    $("#title_img").attr("src","image/contactadd.png");
                    $("#title_text").html("通讯录");
                    //$("#content").html("TAB02");
                    break;
                case 2:
                    localStorage.setItem("iframesrc","find");
                    $("iframe").attr("src","friendgroup.html");
                    //$("iframe").attr("src","none");
                    $(img[2]).attr("src","image/find_pressed.png");
                    //$("#search_i").css("display","none");
                    $("#title_img").css("display","none");
                    $("#title_text").html("发现");
                    //$("#content").html("TAB03");
                    break;
                case 3:
                    localStorage.setItem("iframesrc","me");
                    //$("iframe").attr("src","none");
                    $("iframe").attr("src","me.html");
                    $(img[3]).attr("src","image/me_pressed.png");
                    //$("#search_i").css("display","none");
                    $("#title_img").css("display","none");
                    $("#title_text").html("我");
                    //$("#content").html("TAB04");
                    break;
                default :
                    break;
            }
            $(item).nextAll("span").css("color","green");
        })
    })
});
function tab_normal(){
    $("#foot span").css("color","gray");
    $("#tab1").attr("src","image/message_normal.png");
    $("#tab2").attr("src","image/contact_normal.png");
    $("#tab3").attr("src","image/find_normal.png");
    $("#tab4").attr("src","image/me_normal.png");
}